package sz.szsmk.citizencard.mvp.presenter;

import com.google.gson.Gson;

import javax.inject.Inject;

import sz.szsmk.citizencard.model.network.GsdxNetApi;
import sz.szsmk.citizencard.model.network.bean.request.QueryCollectedStandreq;
import sz.szsmk.citizencard.model.network.bean.response.QueryNearStandbyRes;
import sz.szsmk.citizencard.mvp.contract.IBusSiteCollectContact;
import sz.szsmk.citizencard.mvp.contract.ICouponGetContact;
import sz.szsmk.citizencard.retrofitrxjava.ErrorAction;
import sz.szsmk.citizencard.retrofitrxjava.NetworkDateSources;
import sz.szsmk.citizencard.retrofitrxjava.SubscribeResult;

/**
 * Copyright (c)2018
 * author: zdh
 * created on: 2018/11/15 9:52
 * description:
 */
public class CouponGetPresenter extends IBasePresenter
implements ICouponGetContact.ICouponGetPresenter<ICouponGetContact.ICouponGetView> {


    private NetworkDateSources mNetworkDateSource;
    GsdxNetApi gsdxNetApi;

    @Inject
    public CouponGetPresenter(GsdxNetApi gsdxNetApi) {
        this.gsdxNetApi = gsdxNetApi;

        this.mNetworkDateSource = NetworkDateSources.getInstance();
    }

    @Override
    public void getDataList(String s, String keyword) {

        QueryCollectedStandreq queryCollectedStandreq = new QueryCollectedStandreq();
        queryCollectedStandreq.setUserID(keyword);
        String json = new Gson().toJson(queryCollectedStandreq);
        mNetworkDateSource.queryCollectedStand(queryCollectedStandreq, new SubscribeResult<QueryNearStandbyRes>() {
            @Override
            protected void onOk(QueryNearStandbyRes response) {
                ((IBusSiteCollectContact.IBusSiteCollectView) mView).getDataListSucc(response);
            }

            @Override
            protected void onFailure(QueryNearStandbyRes response) {
                super.onFailure(response);

            }
        }, new ErrorAction() {
            @Override
            public void onCall(Throwable throwable) {

            }
        });
//        QueryNearStandbyReq queryNearStandbyReq = new QueryNearStandbyReq();
//        queryNearStandbyReq.setLatitude(s);
//        queryNearStandbyReq.setLongitude(keyword);
//        queryNearStandbyReq.setUserID("string");
//        mNetworkDateSource.queryNearStandby(queryNearStandbyReq, new SubscribeResult<QueryNearStandbyRes>() {
//            @Override
//            protected void onOk(QueryNearStandbyRes response) {
//                String json = new Gson().toJson(response);
//                L.e(Constant.TAG,"------------"+json);
//                ((IBusSiteNearbyContact.IBusSiteNearbyView) mView).getDataListSucc(response);
//            }
//
//            @Override
//            protected void onFailure(QueryNearStandbyRes response) {
//                super.onFailure(response);
//            }
//        }, new ErrorAction() {
//            @Override
//            public void onCall(Throwable throwable) {
//
//            }
//        });
    }

}
